﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lincolnwood.Foundation.Common.Data;

namespace Lincolnwood.Foundation.Scheduling
{
    public abstract class PatternDeviation : AuditableEntity<Guid>, IComparable<PatternDeviation>, IComparable
    {
        private DateTime _originalDate;

        protected PatternDeviation()
        {

        }

        public PatternDeviation(DateTime originalDate)
        {
            _originalDate = originalDate;

        }

        public DateTime OriginalDate
        {
            get { return _originalDate; }
            internal set { _originalDate = value; }
        }

        public int CompareTo(PatternDeviation other)
        {
            if (other == null)
                return 1;

            return this.OriginalDate.CompareTo(other.OriginalDate);
        }

        public int CompareTo(object obj)
        {           
            PatternDeviation objToCompare = obj as PatternDeviation;
            if (objToCompare != null)
                return this.CompareTo(objToCompare);
            else
                throw new ArgumentException("Object is not a PatternDeviation");
        }

        public override bool Equals(object obj)
        {
            if (obj == null) return false;

            PatternDeviation objToCompare = obj as PatternDeviation;
            if (objToCompare == this)
                return true;

            if (objToCompare != null)
                return this.OriginalDate.Equals(objToCompare.OriginalDate);
            else
                throw new ArgumentException("Object is not a PatternDeviation");
        }

        public override int GetHashCode()
        {
            return this.OriginalDate.GetHashCode();
        }
    }
}
